#!/bin/sh

set -e

DEB_PACKAGE='darling'

ARGS_FILE="$(mktemp)"

find "debian/${DEB_PACKAGE}" -type f -exec tools/debian/make-shlibdeps-file "${ARGS_FILE}" {} \;

OUT="$(mktemp)"
clang -shared -o "${OUT}"$(cat ${ARGS_FILE})
dpkg-shlibdeps -T"debian/${DEB_PACKAGE}.substvars" -p"macho" -e"${OUT}" > /dev/null 2>&1

rm -f "${ARGS_FILE}"
rm -f "${OUT}"
